package com.system.service;

import com.system.dao.StudentDao;
import com.system.domain.Student;
import java.util.ArrayList;


public class StudentService {
    private StudentDao studentDao = new StudentDao();
    private ArrayList<Student> list = studentDao.getStuInfo();

    public boolean addStudent(Student student) {
        return studentDao.add(student);
    }

    public int isExists(String id) {
        int index=-1;
        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            if(id.equals(student.getId())){
                index=i;
            }
        }
        return index;
    }

    public ArrayList<Student> show() {
        return list;
    }

    public void deleteStu(int index) {
        studentDao.delete(index);
    }

    public void updateStu(int index, Student student) {
        studentDao.update(index,student);
    }

}
